﻿package core.image.decoder
{
    import __AS3__.vec.*;
    import core.enum.*;
    import core.image.*;
    import flash.utils.*;

    public class PBRDecoder extends Object
    {
        var version:int;
        var numbrushes:int;

        public function PBRDecoder()
        {
            return;
        }// end function

        public function decode(_local3:ByteArray) : Vector.<Brush>
        {
            var _loc_2:ByteArray = null;
            var _loc_4:int = 0;
            _local3.uncompress();
            this.version = _local3.readShort();
            this.numbrushes = _local3.readShort();
            var _loc_3:* = new Vector.<Brush>;
            while (_loc_4 < this.numbrushes)
            {
                
                _loc_2 = new ByteArray();
                _local3.readBytes(_loc_2, 0, _local3.readUnsignedInt());
                _loc_3.push(this.ReadBrush(_loc_2));
                _loc_4++;
            }
            return _loc_3;
        }// end function

        private function ReadBrush(_local4:ByteArray) : Brush
        {
            var _loc_2:int = 0;
            var _loc_3:* = _local4.readInt();
            var _loc_4:* = _local4.readInt();
            var _loc_5:* = _local4.readInt();
            var _loc_6:* = -1;
            var _loc_7:* = new Vector.<int>;
            _loc_2 = _local4.readUnsignedInt();
            while (++_loc_6 < _loc_2)
            {
                
                _loc_7.push(_local4.readUnsignedByte());
            }
            return new Brush(BrushType.Custom, _loc_7, _loc_3, _loc_4, _loc_5, null);
        }// end function

    }
}
